

<%@page import="DAL.StudentDAO"%>
<%@page import="DAL.MyConnection"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body style="background-image: url('http://localhost:8080/ftico_project/pic/hinh-nen-hd-dep-cho-may-tinh-canh-bien-wallpaper-12.jpg')" >
        <div align = "center">
        <h1>All of students</h1>
        <form method = 'GET'>
        </form>
        </div>
        <%
            try {
                Connection con = MyConnection.getConnection();
                StudentDAO studentDAO = new StudentDAO(con);
                String query = "select * from Stu";
                String sort = request.getParameter("sort");
                if(sort != null){
                    if(sort.equals("ageup"))
                        query = "select * from student order by age";
                    else
                        query = "select * from student order by age desc";
                }
                String result = studentDAO.listAll(query);
                out.println(result);
            } catch (Exception ex) {
                out.println(ex.getMessage());
            }
            
        %>
        <div align="center" style="font-size: 10px">
            <a HREF ="menu.html" style="text-decoration:none;" ><h2>Return Menu</h2></a>
            <a HREF ="login.jsp" style="text-decoration:none;" ><h2>Logout</h2></a>
        </div>
        
        
    </body>
</html>
